/**
 * Copyright (c) 2020 纵腾开源 All rights reserved.
 * <p>
 *
 * <p>
 * 版权所有，侵权必究！
 */
package com.base.test.security.impl;

import com.base.commons.tools.utils.Result;
import com.base.test.security.user.UserDetail;
import com.base.test.security.feign.AccountFeignClient;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

/**
 * UserDetailsService
 *
 * @author Mark sunlightcs@gmail.com
 */
@Service
public class BscUserDetailsServiceImpl implements UserDetailsService {
    @Autowired(required=false)
    private AccountFeignClient accountFeignClient;

    @Override
    public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException {
        Result<UserDetail> result = accountFeignClient.getByUsername(username);
        UserDetail userDetail = result.getData();
        return userDetail;
    }
}
